package com.mercury.pattern._18_memo.demo;

public class Client {
    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();

        Originator o1 = new Originator();
        o1.setState("状态1");
        caretaker.add(o1.saveMemo());

        o1.setState("状态2");
        caretaker.add(o1.saveMemo());

        o1.setState("状态3");
        caretaker.add(o1.saveMemo());

        System.out.println("当前状态为：" +  o1.getState());

        o1.restoreMemo(caretaker.get(0));
        System.out.println("恢复后状态为：" +  o1.getState());
    }
}
